home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_055 / vt100 / vt100.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  18KB  |  721 lines

  1. /********************************************************************
  2.  *  vt100 terminal emulator with xmodem transfer capability
  3.  *
  4.  *    v2.6 870227 DBW - bug fixes for all the stuff in v2.5
  5.  *    v2.5 870214 DBW - more additions (see readme file)
  6.  *    v2.4 861214 DBW - lots of fixes/additions (see readme file)
  7.  *    v2.3 861101 DBW - minor bug fixes
  8.  *    v2.2 861012 DBW - more of the same
  9.  *    v2.1 860915 DBW - new features (see README)
  10.  *         860901 ACS - Added Parity and Word Length and support code
  11.  *         860823 DBW - Integrated and rewrote lots of code
  12.  *    v2.0 860809 DBW - Major rewrite
  13.  *    v1.1 860720 DBW    - Switches, 80 cols, colors, bug fixes
  14.  *    v1.0 860712 DBW    - First version released
  15.  *
  16.  *  use <esc> to abort xmodem or kermit transfers
  17.  *
  18.  *  written by Michael Mounier
  19.  *  new version by Dave Wecker
  20.  *******************************************************************/
  21.  
  22. /*  all includes defines and globals */
  23. #include "vt100.h"
  24.  
  25. /**************************************************************/
  26. /* here are all the global definitions that appear in vt100.h */
  27. /**************************************************************/
  28.  
  29. char    bufr[BufSize];
  30. int     fd, timeout = FALSE, ttime;
  31. int    multi = FALSE, server;
  32. long    bytes_xferred;
  33. char    MyDir[60];
  34. struct    FileLock *MyDirLock = NULL;
  35. struct    FileLock *StartLock = NULL;
  36. struct    IntuitionBase *IntuitionBase;
  37. struct    GfxBase *GfxBase;
  38.  
  39. struct    TextAttr myattr = {
  40.     (STRPTR) "topaz.font",
  41.     8,
  42.     0,
  43.     0};
  44. struct    TextFont *myfont = NULL;
  45. struct NewScreen NewScreen = {
  46.    0L,0L,640L,200L,1L,       /* left, top, width, height, depth */
  47.    0,1,HIRES,    /* DetailPen, BlockPen, ViewModes */
  48.    CUSTOMSCREEN,&myattr,   /* Type, Font */
  49.    (UBYTE *)"VT100", /* Title */
  50.    NULL,NULL };         /* Gadgets, Bitmap */
  51. struct NewWindow NewWindow = {
  52.    0,0L,640L,200L,     /* left, top, width, height */
  53.    0,1,              /* detailpen, blockpen */
  54.    MENUPICK|CLOSEWINDOW|RAWKEY|REQCLEAR|REQSET|ACTIVEWINDOW|INACTIVEWINDOW,
  55.    SMART_REFRESH|ACTIVATE|BORDERLESS|WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG,
  56.    NULL,NULL,        /* FirstGadget, CheckMark */
  57.    (UBYTE *)NULL,
  58.    NULL,             /* set screen after open screen */
  59.    NULL,             /* bitmap */
  60.    640L, 200L, 640L, 200L,/* minw, minh, maxw, maxh */
  61.    CUSTOMSCREEN      /* Type */
  62.    };
  63. struct IntuiText MyTitle = {
  64.     0,1,JAM2,26,0,    /* front pen, back pen, mode, left, top */
  65.     &myattr,        /* font */
  66.     (UBYTE *)VERSION,    /* title */
  67.     NULL};        /* next text */
  68. struct Screen *myscreen = NULL;      /* ptr to applications screen */
  69. struct Window *mywindow = NULL;     /* ptr to applications window */
  70. struct ViewPort *myviewport;
  71. struct RastPort *myrastport;
  72. struct IntuiMessage *NewMessage;    /* msg structure for GetMsg() */
  73. struct Preferences  *Prefs;        /* preferences from GetPrefs() */
  74.  
  75. /**** String requester support ******/
  76.  
  77. char    InpBuf[80],UndoBuf[80],Prompt[80];
  78. struct IntuiText donetxt = {
  79.     1,0,JAM2,0,0,    /* front pen, back pen, mode, left, top */
  80.     &myattr,        /* font */
  81.     (UBYTE *)"DONE",    /* question to ask */
  82.     NULL};        /* next text */
  83. struct Gadget mydonegad = {
  84.     NULL,290,2,40,10,/* next,left,top,width,height */
  85.     GADGHCOMP|REQGADGET,/* flags */
  86.     RELVERIFY|ENDGADGET,/* activation */
  87.     BOOLGADGET,        /* gadget type */
  88.     NULL,NULL,&donetxt,    /* gad render, sel render, gad text */
  89.     0L,NULL,2,NULL};    /* mutual exclude, special, ID, user data */
  90. struct    StringInfo mystrinfo = {
  91.     (UBYTE *)InpBuf,
  92.     (UBYTE *)UndoBuf,
  93.     0,80,0,0,0,0,    /* initial, max, disp, undo, #chrs, dsp chrs */
  94.     0,0,NULL,0L,NULL};    /* left,top,layer,longint,keymap */
  95. struct Gadget mystrgad = {
  96.     &mydonegad,10,12,320,10,    /* next,left,top,width,height */
  97.     GADGHCOMP|REQGADGET,/* flags */
  98.     ENDGADGET,STRGADGET,/* activation, type */
  99.     NULL,NULL,NULL,    /* gad render, sel render, gad text */
  100.     0L,            /* mutual exclude */
  101.     (APTR)&mystrinfo,    /* special info */
  102.     1,NULL};        /* gadget ID, user data */
  103. struct IntuiText mystrtxt = {
  104.     0,1,JAM2,10,2,    /* front pen, back pen, mode, left, top */
  105.     &myattr,        /* font */
  106.     (UBYTE *)Prompt,    /* question to ask */
  107.     NULL};        /* next text */
  108. struct Requester myrequest = {
  109.     NULL,200,40,340,22,    /* older requester, left, top, width, height */
  110.     0,0,&mystrgad,    /* relleft reltop, gadgets */
  111.     NULL,        /* border */
  112.     &mystrtxt,        /* text */
  113.     NULL,1,NULL,    /* flags, back fill pen, layer */
  114.     {0,0,0,0,0,0,0,0,
  115.      0,0,0,0,0,0,0,0,
  116.      0,0,0,0,0,0,0,0,
  117.      0,0,0,0,0,0,0,0},    /* pad1 */
  118.     NULL,NULL,        /* image bit map, rquest window */
  119.     {0,0,0,0,0,0,0,0,0,
  120.      0,0,0,0,0,0,0,0,0,
  121.      0,0,0,0,0,0,0,0,0,
  122.      0,0,0,0,0,0,0,0,0} /* pad2 */
  123.     };
  124. int numreqs = 0;    /* number of outstanding requestors */
  125.  
  126. /***** menu structures *****/
  127. struct MenuItem FileItem[FILEMAX];
  128. struct IntuiText FileText[FILEMAX];
  129. struct MenuItem CommItem[COMMAX];
  130. struct IntuiText CommText[COMMAX];
  131. struct MenuItem RSItem[RSMAX];
  132. struct IntuiText RSText[RSMAX];
  133. struct MenuItem ParItem[PARMAX];
  134. struct IntuiText ParText[PARMAX];
  135. struct MenuItem XFItem[XFMAX];
  136. struct IntuiText XFText[XFMAX];
  137. struct MenuItem ScriptItem[SCRIPTMAX];
  138. struct IntuiText ScriptText[SCRIPTMAX];
  139. struct MenuItem UtilItem[UTILMAX];
  140. struct IntuiText UtilText[UTILMAX];
  141. struct Menu menu[MAXMENU];
  142. struct IOExtSer *Read_Request;
  143. char *rs_in;
  144. struct IOExtSer *Write_Request;
  145. char rs_out[2];
  146. struct timerequest Timer;
  147. struct MsgPort *Timer_Port = NULL;
  148. struct timerequest Script_Timer;
  149. struct MsgPort *Script_Timer_Port = NULL;
  150. struct IOAudio Audio_Request;
  151. struct MsgPort *Audio_Port = NULL;
  152. UBYTE  *BeepWave;
  153. UBYTE  Audio_AllocMap[4] = { 1, 8, 2, 4 };
  154. int x,y,curmode;
  155. int MINX    = 0;
  156. int MAXX    = 632;
  157. int MINY    = 14;
  158. int MAXY    = 198;
  159. int top        = 14;
  160. int bot        = 198;
  161. int savx    = 0;
  162. int savy    = 14;
  163. int savmode    = 0;
  164. int nlmode    = 0;
  165. int alt        = 0;
  166. int savalt    = 0;
  167. int a[2]    = { 0, 0 };
  168. int sa[2]    = { 0, 0 };
  169. int  inesc    = -1;
  170. int  inctrl    = -1;
  171. int  private    = 0;
  172. int  badseq    = 0;
  173. int  maxcol    = 79;
  174.  
  175. /*************************** defaults *******************************/
  176. int    p_baud         = 2400;        /* baud rate */
  177. int    p_screen     = 1;        /* 0 = WORKBENCH,        1 = CUSTOM */
  178. int    p_wbcolors   = 1;        /* 0 = Custom, 1 = Workbench colors */
  179. int    p_interlace  = 1;        /* 0 = no interlace,    1 = interlace */
  180. int    p_depth         = 1;        /* number of bit planes (1 or 2) */
  181. int    p_foreground = 0x950;        /* default foreground RGB color */
  182. int    p_background = 0x000;        /* default background RGB color */
  183. int    p_bold         = 0x900;        /* default BOLD       RGB color */
  184. int    p_cursor     = 0x009;        /* default Cursor      RGB color */
  185. int    p_lines         = 48;        /* number of lines on the screen */
  186. int    p_mode         = 1;        /* 0 = image, 1 = CRLF (for kermit) */
  187. int    p_buffer     = 512;        /* read buffer size (>= 512 bytes) */
  188. int     p_parity     = 0;        /* 0=none,1=mark,2=space,3=even,4=odd */
  189. long    p_break         = 750000;        /* break time (in micro seconds) */
  190. int    p_volume     = 64;        /* beep volume (0 = DisplayBeep) */
  191. int    p_wrap         = 0;        /* 0 = truncate, 1 = wrap long lines */
  192. int    p_keyapp     = 0;        /* 0 = numeric, 1 = application keypad */
  193. int    p_curapp     = 0;        /* 0 = cursor, 1 = application cursor */
  194. int    p_echo         = 0;        /* 0 = full duplex, 1 = half duplex */
  195. int    p_bs_del     = 0;        /* 0 = normal, 1 = swap bs and delete */
  196. int    p_convert    = 1;        /* 1 = convert filenames to lower case */
  197. char    p_keyscript  = 0x7E;        /* function key script introducer = ~ */
  198. char    *p_f[10]     = {        /* function key defaults */
  199.     "\033OP","\033OQ","\033OR","\033OS",
  200.     "f5","f6","f7","f8","f9","f10" };
  201.  
  202. char    *p_F[10]     = {        /* shifted function key defaults */
  203.     "F1","F2","F3","F4","F5",
  204.     "F6","F7","F8","F9","F10"};
  205.  
  206. /* for script file */
  207. int script_on;
  208. int script_wait;
  209. int doing_init = 0;
  210.  
  211. /******************************************************/
  212. /*                   Main Program                     */
  213. /*                                                    */
  214. /*      This is the main body of the program.         */
  215. /******************************************************/
  216.  
  217. char lookahead[80];
  218. FILE *tranr = NULL;
  219. FILE *trans = NULL;
  220. int capture,send;
  221. char name[80];
  222. struct MsgPort *mySerPort;
  223.  
  224. main(argc,argv)
  225. int    argc;
  226. char    **argv;
  227.     {
  228.     ULONG class;
  229.     unsigned int code, qual;
  230.     int KeepGoing,i,la,dola,actual;
  231.     char c,*ptr;
  232.  
  233.     ptr = InitDefaults(argc,argv);
  234.     InitDevs();
  235.     InitFileItems();
  236.     InitCommItems();
  237.     InitScriptItems();
  238.     InitUtilItems();
  239.     InitMenu();
  240.     SetMenuStrip(mywindow,&menu[0]);
  241.     PrintIText(mywindow->RPort,&MyTitle,0L,0L);
  242.  
  243.     MyDir[0]  =        '\000';
  244.     StartLock =    (struct FileLock *)((ULONG)((struct Process *)
  245.             (FindTask(NULL)))->pr_CurrentDir);
  246.     MyDirLock = (struct FileLock *)DupLock(StartLock);
  247.     KeepGoing =        TRUE;
  248.     capture   =        FALSE;
  249.     send      =        FALSE;
  250.     maxcol    =        MAXX / 8;
  251.     la          =        0;
  252.     x          =        MINX ; 
  253.     y          =        MINY; 
  254.     curmode   =        FS_NORMAL;
  255.     script_on =     FALSE;
  256.     script_wait=    TRUE;
  257.     SetAPen(mywindow->RPort,1L);
  258.     cursorflip();
  259.     cursorflip();    
  260.     emit(12);
  261.     mySerPort = Read_Request->IOSer.io_Message.mn_ReplyPort;
  262.     SendIO(Read_Request);
  263.  
  264.     /* see if we had a startup script */
  265.     if (ptr != NULL) script_start(ptr);
  266.  
  267.     while( KeepGoing )
  268.         {
  269.         /* wait for window message or serial port message */
  270.         cursorflip();
  271.         if (script_wait)    /* if script ready dont wait here */
  272.         Wait(
  273.          (1L << mySerPort->mp_SigBit) |
  274.          (1L << mywindow->UserPort->mp_SigBit) |
  275.          (1L << Script_Timer_Port->mp_SigBit));
  276.         cursorflip();
  277.         
  278.         /* do ascii file send */
  279.         if (send)
  280.         {
  281.         if ((c=getc(trans)) != EOF) {
  282.             if (c == '\n') c = '\r';
  283.             sendchar(c);
  284.             }
  285.         else {
  286.             fclose(trans);
  287.             req("File Sent","",0);
  288.             send=FALSE;
  289.             }
  290.         }
  291.  
  292.         /* see if there are any characters from the host */
  293.         if (CheckIO(Read_Request)) {
  294.         WaitIO(Read_Request);
  295.         c = rs_in[0] & 0x7F;
  296.         doremote(c);
  297.         if (script_on) chk_script(c);
  298.             if (capture && c != 10) {
  299.                   if (c == 13) c = 10;
  300.             putc(c , tranr);
  301.             }
  302.         Read_Request->IOSer.io_Command = SDCMD_QUERY;
  303.         DoIO(Read_Request);
  304.         Read_Request->IOSer.io_Command = CMD_READ;
  305.         actual = (int)Read_Request->IOSer.io_Actual;
  306.         if (actual > 0) {
  307.             if (inesc   <  0 &&
  308.             inctrl  <  0 &&
  309.             a[alt]  == 0 &&
  310.             capture == FALSE) dola = 1;
  311.             else dola = 0;
  312.             Read_Request->IOSer.io_Length =
  313.             Read_Request->IOSer.io_Actual;
  314.             DoIO(Read_Request);
  315.             Read_Request->IOSer.io_Length = 1;
  316.  
  317.             for (i = 0; i < actual; i++) {
  318.             c=rs_in[i] & 0x7f;
  319.             if (script_on) chk_script(c);
  320.  
  321.             if (dola == 1) {
  322.                 if (c >= ' ' && c <= '~' && la < 80)
  323.                 lookahead[la++] = c;
  324.                 else {
  325.                 if (la > 0) {
  326.                     emitbatch(la,lookahead);
  327.                     la = 0;
  328.                     }
  329.                 doremote(c);
  330.                 dola = 0;
  331.                 }
  332.                 }
  333.             else {
  334.                 doremote(c);
  335.                 if (inesc   <  0 &&
  336.                 inctrl  <  0 &&
  337.                 a[alt]  == 0 &&
  338.                 capture == FALSE) dola = 1;
  339.                 if (capture && c != 10) {
  340.                 if (c == 13) c = 10;
  341.                 putc(c , tranr);
  342.                 }
  343.                 }
  344.             }
  345.  
  346.             /* dump anything left in the lookahead buffer */
  347.             if (la > 0) {
  348.             emitbatch(la,lookahead);
  349.             la = 0;
  350.             }
  351.             }
  352.         SendIO(Read_Request);
  353.         }
  354.  
  355.         while((NewMessage = 
  356.             (struct IntuiMessage *)GetMsg(mywindow->UserPort))
  357.             != FALSE) {
  358.         class = NewMessage->Class;
  359.         code = NewMessage->Code;
  360.         qual = NewMessage->Qualifier;
  361.         ReplyMsg( NewMessage );
  362.         switch( class )
  363.             {
  364.             case REQCLEAR:
  365.             numreqs = 0;
  366.             break;
  367.  
  368.             case CLOSEWINDOW:
  369.             KeepGoing = FALSE;
  370.             break;
  371.  
  372.             case RAWKEY:
  373.             c = toasc(code,qual,0);
  374.             if (p_echo) doremote(c);
  375.             break;
  376.  
  377.             case NEWSIZE:
  378.             emit(12);
  379.             break;
  380.  
  381.             case MENUPICK:
  382.             handle_menupick(class,code);
  383.             break;                    
  384.  
  385.             default:
  386.             PrintIText(mywindow->RPort,&MyTitle,0L,0L);
  387.             break;
  388.             }   /* end of switch (class) */
  389.         }   /* end of while ( newmessage )*/
  390.  
  391.             if (!script_wait || 
  392.                  (CheckIO(&Script_Timer) && 
  393.             script_wait == WAIT_TIMER))
  394.         do_script_cmd(NEXTCOMMAND);
  395.         }  /* end while ( keepgoing ) */
  396.         
  397.     /*   It must be time to quit, so we have to clean
  398.     *   up and exit.
  399.     */
  400.  
  401.     cleanup("",0);
  402.  
  403.     } /* end of main */
  404.  
  405. /* cleanup code */
  406.  
  407. cleanup(reason, fault)
  408. char *reason;
  409. int fault;
  410.     {
  411.     switch(fault) {
  412.     case 0:        /* quitting close everything */
  413.     ClearMenuStrip( mywindow ); 
  414.     CloseDevice(&Audio_Request);
  415.     if (MyDirLock != NULL) UnLock(MyDirLock);
  416.  
  417.     case 8:        /* error opening audio */
  418.     DeletePort(Audio_Port);
  419.     FreeMem(BeepWave,BEEPSIZE);
  420.     CloseDevice(&Timer);
  421.  
  422.     case 7:        /* error opening timer */
  423.     DeletePort(Timer_Port);  
  424.     CloseDevice(&Script_Timer);
  425.     DeletePort(Script_Timer_Port);
  426.  
  427.     case 6:        /* error opening write device */
  428.     DeletePort(Write_Request->IOSer.io_Message.mn_ReplyPort);
  429.     FreeMem(Write_Request,(long)sizeof(*Write_Request));
  430.     CloseDevice(Read_Request);
  431.  
  432.     case 5:        /* error opening read device */
  433.     DeletePort(Read_Request->IOSer.io_Message.mn_ReplyPort);
  434.     FreeMem(Read_Request,(long)sizeof(*Read_Request));
  435.  
  436.     case 4:        /* error opening window */
  437.     if (myfont   != NULL) CloseFont( myfont );
  438.     if (mywindow != NULL) CloseWindow( mywindow );
  439.     if (p_screen != 0) CloseScreen( myscreen );
  440.  
  441.     case 3:        /* error opening screen */
  442.     case 2:        /* error opening graphics library */
  443.     case 1:        /* error opening intuition */
  444.     default:
  445.     if (*reason) puts (reason);
  446.     }
  447.     exit(fault);
  448.     } 
  449.  
  450. do_capture(file)
  451. char *file;
  452.     {
  453.     if (capture == TRUE)
  454.         {
  455.         capture=FALSE;
  456.         fclose(tranr);
  457.         req("End File Capture","",0);
  458.         }
  459.     else
  460.         {
  461.         if (file == NULL) {
  462.         name[0] = '\000';
  463.             req("Ascii Capture:",name,1);
  464.         } 
  465.     else strcpy(name, file);
  466.         if ((tranr=fopen(name,"w")) == 0) {
  467.         capture=FALSE;
  468.         req("Error Opening File","",0);
  469.         return(FALSE);
  470.         }
  471.     capture=TRUE;
  472.         }
  473.     }
  474.  
  475. do_send(file)
  476. char *file;
  477.     {
  478.     if (send == TRUE)
  479.     { 
  480.         send=FALSE;
  481.         fclose(trans);
  482.         req("File Send Cancelled","",0);
  483.         }
  484.     else
  485.         {
  486.         if (file == NULL) {
  487.         name[0] = '\000';
  488.             req("Ascii Send:",name,1);
  489.             }
  490.     else strcpy(name, file);
  491.         if ((trans=fopen(name,"r")) == 0) {
  492.            send=FALSE;
  493.         req("Error Opening File","",0);
  494.         return(FALSE);
  495.         }
  496.     send=TRUE;
  497.     }
  498.     }
  499.  
  500. void setparams()
  501.     {
  502.     Read_Request->IOSer.io_Command = 
  503.     Write_Request->IOSer.io_Command = 
  504.         SDCMD_SETPARAMS;
  505.     DoIO(Read_Request); DoIO(Write_Request);
  506.     Read_Request->IOSer.io_Command = CMD_READ;
  507.     SendIO(Read_Request);
  508.     Write_Request->IOSer.io_Command = CMD_WRITE;
  509.     }
  510.  
  511. void hangup ()
  512.     {
  513.     AbortIO(Read_Request);
  514.     CloseDevice (Read_Request);
  515.     Timer.tr_time.tv_secs=0L;
  516.     Timer.tr_time.tv_micro=750000L;
  517.     DoIO((char *) &Timer.tr_node);
  518.     OpenDevice (SERIALNAME,NULL,Read_Request,NULL);
  519.     setparams();
  520.     }
  521.  
  522. void redocomm() {
  523.     ClearMenuStrip( mywindow );         /* Remove old menu */
  524.     InitCommItems();                    /* Re-do comm menu   */
  525.     SetMenuStrip(mywindow,&menu[0]);    /* Re-display the menu */    
  526.     }
  527.  
  528. void setserbaud(baud, redomenu)
  529. int baud;
  530. LONG redomenu;
  531.     {
  532.     AbortIO(Read_Request);
  533.     Write_Request->io_Baud = Read_Request->io_Baud = baud;
  534.     setparams();
  535.     p_baud = baud;
  536.     if (redomenu) redocomm();
  537.     }
  538.  
  539. void redoutil() {
  540.     ClearMenuStrip(mywindow);
  541.     InitUtilItems();
  542.     SetMenuStrip(mywindow,&menu[0]);
  543.     }
  544.  
  545. void handle_menupick(class, code)
  546. ULONG class;
  547. unsigned int code;
  548.     {
  549.     unsigned int menunum, itemnum, subnum;
  550.  
  551.     if (code == MENUNULL) return;
  552.  
  553.     menunum = MENUNUM( code );
  554.     itemnum = ITEMNUM( code );
  555.     subnum  = SUBNUM( code );
  556.     switch( menunum ) {
  557.     case 0:
  558.     switch( itemnum ) {
  559.         case 0:
  560.         do_capture(NULL);
  561.         break;
  562.  
  563.         case 1:
  564.         do_send(NULL);
  565.         break;
  566.  
  567.         case 2:
  568.         if (p_parity > 0) {
  569.         req("Parity setting prevents this","",0);
  570.         break;
  571.         }
  572.         name[0] = '\000';
  573.         req("Xmodem Receive:",name,1);
  574.         multi_xfer(name,XMODEM_Read_File,0);
  575.         break;
  576.  
  577.         case 3:
  578.         if (p_parity > 0) {
  579.         req("Parity setting prevents this","",0);
  580.         break;
  581.         }
  582.         name[0] = '\000';
  583.         req("Xmodem Send:",name,1);
  584.         multi_xfer(name,XMODEM_Send_File,1);
  585.         break;
  586.  
  587.         case 4:
  588.         server = TRUE;
  589.         name[0] = '\000';
  590.         req("Kermit GET remote file(s):",name,1);
  591.         multi_xfer(name,dokreceive,0);
  592.             break;
  593.  
  594.         case 5:
  595.         multi_xfer("",dokreceive,0);
  596.         break;
  597.  
  598.         case 6:
  599.         server = TRUE;
  600.         name[0] = '\000';
  601.         req("Kermit Send local name:",name,1);
  602.         multi_xfer(name,doksend,1);
  603.         break;
  604.  
  605.         case 7:
  606.         saybye();
  607.         break;
  608.         }
  609.     break;
  610.  
  611.     case 1:
  612.     switch( itemnum ) {
  613.         case 0:
  614.         switch( subnum ) {
  615.         case 0:
  616.         setserbaud(300, FALSE);
  617.         break;
  618.  
  619.         case 1:
  620.         setserbaud(1200, FALSE);
  621.         break;
  622.  
  623.         case 2:
  624.         setserbaud(2400, FALSE);
  625.         break;
  626.  
  627.         case 3:
  628.         setserbaud(4800, FALSE);
  629.         break;
  630.  
  631.         case 4:
  632.         setserbaud(9600, FALSE);
  633.         break;
  634.         }
  635.         break;        
  636.  
  637.         case 1:
  638.         /* Set  Parity */
  639.         p_parity = subnum;
  640.         break;
  641.  
  642.         case 2:
  643.         /* set transfer mode */
  644.         if (subnum < 2) p_mode = subnum;
  645.         else {
  646.         if (p_convert)    p_convert = 0;
  647.         else        p_convert = 1;
  648.         redocomm();
  649.         }
  650.         break;
  651.         }
  652.     break;
  653.  
  654.     case 2:
  655.     if (!itemnum && !script_on) {
  656.         name[0] = '\000';
  657.         req("Script file name:",name,1);
  658.         script_start(name);
  659.         }
  660.     if (itemnum && script_on) exit_script();
  661.     break;
  662.  
  663.     case 3:
  664.     switch( itemnum ) {
  665.         case 0:
  666.         sendbreak();
  667.         break;
  668.  
  669.         case 1:
  670.         hangup();
  671.         break;
  672.  
  673.         case 2:
  674.         strcpy(name,MyDir);
  675.         req("Directory:",name,1);
  676.         set_dir(name);
  677.         break;
  678.  
  679.         case 3:
  680.         top = MINY; bot = MAXY; savx = MINX; savy = MINY;
  681.         curmode = FS_NORMAL; inesc = -1;
  682.         a[0] = 0; a[1] = 0; sa[0] = 0; sa[1] = 0;
  683.         redoutil();
  684.         emit(12);
  685.         break;
  686.  
  687.         case 4:
  688.         if (p_echo) p_echo = 0;
  689.         else    p_echo = 1;
  690.         redoutil();
  691.         break;
  692.  
  693.         case 5:
  694.         if (p_wrap) p_wrap = 0;
  695.         else        p_wrap = 1;
  696.         redoutil();
  697.         break;
  698.  
  699.         case 6:
  700.         if (p_keyapp) p_keyapp = 0;
  701.         else          p_keyapp = 1;
  702.         redoutil();
  703.         break;
  704.  
  705.         case 7:
  706.         if (p_curapp) p_curapp = 0;
  707.         else          p_curapp = 1;
  708.         redoutil();
  709.         break;        
  710.  
  711.         case 8:
  712.         swap_bs_del();
  713.         redoutil();
  714.         break;
  715.         }
  716.  
  717.     break;
  718.     } /* end of switch ( menunum ) */
  719.     }
  720.  
  721.